<!--#
layout("/layouts/store.html"){
#-->
<style>
    .rule-group-cnd,.rule-group-act{
        margin: 5px 5px 5px 15px; padding: 5px;display: none;
    }
    .rule-cnd-def ul{
        list-style-type:none
    }
    .rule-cnd-def ul li{
        padding: 5px;
    }
    .cnd-panel{
        overflow-x:auto; white-space:nowrap;
    }
    .cnd-del{
        cursor:pointer;padding: 5px;
    }

    .rule-price-input-sm{
        width: 60px;
    }
    .rule-input-sm{
        width: 50px;
    }
    .member-lvs{
        display: inline-block
    }
    .member-lv-inline {
        position: relative;
        display: inline-block;
        padding-top: 7px;
        padding-left: 1px;
        margin-bottom: 0;
        font-weight: 400;
        vertical-align: middle;
    }
    .rule-input-rate{
        width: 100px;min-width: 80px;
    }
    .rule-input-price{
        width: 120px;min-width: 100px;
    }
    .rule-input-number{
        width: 60px;min-width: 40px;
    }
</style>
<link rel="stylesheet" href="${base!}/assets/platform/vendor/layui/css/layui.css">
<header class="header navbar bg-white shadow">
    <div class="btn-group tool-button">
        <a class="btn btn-primary navbar-btn" href="${base}/store/sales/coupon" id="goBack" data-pjax><i class="ti-angle-left"></i>${msg['globals.button.back']}</a>
    </div>
    <div class="pull-right">
        <div class="btn-group tool-button">
            <!--<button class="btn btn-primary navbar-btn js-to-check" data-loading-text="${msg['globals.button.submit.tip']}" >保存并提交审核</button>-->
            <button class="btn btn-primary navbar-btn js-save" data-loading-text="${msg['globals.button.submit.tip']}" > ${msg['globals.button.save']}</button>
            <a id="doLink" href="${base}/store/sales/coupon/add" data-pjax></a>
        </div>
    </div>
</header>

<div class="content-wrap">
    <div class="wrapper" style="min-height:500px;">
        <section class="panel panel-form">
            <form id="addForm" role="form" class="form-horizontal parsley-form" data-parsley-validate action="${base}/store/sales/coupon/addDo" method="post">
                <input type="hidden" name="id" value="${obj.id!}"/>
                <div class="tab-content">
                    <!--优惠券-->
                    <div class="tab-pane fade active in" id="base">
                        <div class="row mb10 mt10">
                            <div class="col-lg-12">
                                <div class="form-group">
                                    <label for="name" class="col-sm-2 control-label">${msg['sales.coupon.column.name']}</label>
                                    <div class="col-sm-5">
                                        <input type="text" id="name" value="${obj.name!}" class="form-control" name="name" data-parsley-required="true" placeholder="${msg['sales.coupon.column.name']}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="codeprefix" class="col-sm-2 control-label">${msg['sales.coupon.column.codeprefix']}</label>
                                    <div class="col-sm-2">
                                        <input type="text" id="codeprefix" value="${obj.codeprefix!}" class="form-control" name="codeprefix" data-parsley-required="true" placeholder="${msg['sales.coupon.column.codeprefix']}">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="value" class="col-sm-2 control-label">面值</label>
                                    <div class="col-sm-2">
                                        <input type="text" id="value" value="${obj.value!}" class="form-control" name="value" data-parsley-required="true" placeholder="面值">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">${msg['sales.coupon.column.enabled']}</label>
                                    <div class="col-sm-1 switcha">
                                        <div class="mr15">
                                            <input type="hidden" name="disabled" value="${obj.disabled ? 1 : 0}"/>
                                            <input type="checkbox" name="enabled" class="js-switch-blue" <!--#if(!obj.disabled){#-->checked<!--#}#--> >
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
                <!--</div>-->
            </form>
        </section>
    </div>
</div>
<script src="${base!}/assets/platform/vendor/layui/layui.all.js"></script>
<script type="application/javascript">

    $(document).ready(function () {

        //保存
        $(".js-save").click(function () {
            $('#addForm').submit();

        });

        $('#addForm').ajaxForm({
            dataType: 'json',
            beforeSubmit: function (arr, form, options) {
                form.find("button:submit").button("loading");
            },
            success: function (data, statusText, xhr, form) {
                if (data.code == 0) {
                    Toast.success(data.msg);
                    window.location.href="${base}/store/sales/coupon";
                } else {
                    Toast.error(data.msg);
                }
                form.find("button:submit").button("reset");
            }
        });



        //form表单基础效果
        myForm.init();

    })


    //禁用启用颠倒了
    $("[name='enabled']").change(function () {
        if (this.checked) {
            $("[name='disabled']:hidden").val(0);
        } else {
            $("[name='disabled']:hidden").val(1);
        }
    });





</script>


<!--#}#-->


